#!/bin/bash
### start sim, then start gdb, then sudo start this file
### remember to set pts in sendtoGDB..., and set physical address in readMonitor
echo 0 > all_u
echo 2 > all_x
echo -1 >> all_x
#seq  1 | xargs -i bash -c " 
for i in {1..1000}
do
  echo start once $i:
  cd controlled_plant ;
  tail -n 1 ../all_u | xargs -i sed 's/uu/{}/g' *templ* > z.c ; 
  ./zmake.cmd; sleep 0.1; 
  ./a.out `tail -n 2 ../all_x | xargs `  >t; cat t >> ../all_x ; 
  cd .. 
  tail -n 1 all_x | xargs -i ./sendtoGDBwrite {} ; 
  ./sendtoGDBgo ;
  ./readMonitor >> all_u ;
  ./sendtoGDBgo ;
  echo zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz ok $i
done
#"
#./compareOcatve all_u all_x

